package com.gzyj.server.nettyserver.init;

import com.gzyj.server.config.NettyConfig;
import com.gzyj.server.nettyserver.handler.DispatcherHandler;
import com.gzyj.server.nettyserver.handler.ProtocolDecoder;
import com.gzyj.server.nettyserver.handler.Server808Byte2MsgInHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.timeout.IdleStateHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @author lhj
 */
@Component
public class Server808Channel extends ChannelInitializer<NioSocketChannel> {
    @Autowired
    NettyConfig.NettyServerConfig serverConfig;

    @Autowired
    private Server808Byte2MsgInHandler server808Byte2MsgInHandler;

    @Autowired
    private DispatcherHandler dispatcherHandler;

    @Override
    public void initChannel(NioSocketChannel socketChannel) throws Exception {
        socketChannel.pipeline()
                .addLast(new IdleStateHandler(240, 0, 0))
                .addLast(new ProtocolDecoder())
                .addLast(server808Byte2MsgInHandler)
                .addLast(dispatcherHandler);


    }


}